package com.geostart.constructionland.system.controller;

import com.geostar.constructionland.common.entity.dlbm.DlbmVersion;
import com.geostar.constructionland.common.entity.response.ExtJsAjaxResponse;
import com.geostart.constructionland.system.service.DlbmVersionFeignClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

@Api
@Controller
@RequestMapping(path = "/dlbmVersion")
public class DlbmVersionController {
    @Autowired
    DlbmVersionFeignClient dlbmVersionFeignClient;
    @RequestMapping(path = "/profile")
    public String initPage() {
        return "profile/dlbmbb_version";
    }

    @PostMapping("/list")
    @ResponseBody
    @ApiOperation(value = "获取地类编码版本信息")
    public ExtJsAjaxResponse getDlbmVersions(@NotBlank(message = "页码不能为空")  @RequestParam(value = "page") int pageNo,
                                                @NotBlank(message = "每页数量不能为空") @RequestParam(value = "limit") int pageNum,
                                             @RequestParam("query_param_dlbm_version_name") String versionNumber){
        return dlbmVersionFeignClient.getDlbmVersions(pageNo,pageNum,versionNumber);
    }

    @PostMapping("/addDlbmVersion")
    @ResponseBody
    @ApiOperation("新增地类编码版本信息")
    public ExtJsAjaxResponse saveDlbmVersion(DlbmVersion DlbmVersion){
        return dlbmVersionFeignClient.addDlbmVersion(DlbmVersion);
    }


    @PostMapping("/deleteDlbmVersion")
    @ResponseBody
    @ApiOperation("删除版本信息")
    public ExtJsAjaxResponse deleteDlbmVersion(@RequestParam(value = "versionId") String versionId){
        return dlbmVersionFeignClient.delDlbmVersion(versionId);
    }


    @PostMapping("/updateDlbmVersion")
    @ResponseBody
    @ApiOperation("更新版本信息")
    public ExtJsAjaxResponse updateDlbmVersion(DlbmVersion DlbmVersion){
        return dlbmVersionFeignClient.updateDlbmVersion(DlbmVersion);
    }
}
